<template>
  <div>
    <table-where :forms="forms"></table-where>
    <wms-table ref="tableQuery" :tableDatas="tableDatas" @confirmHandle="confirmHandle"></wms-table>
  </div>
</template>

<script setup name="待卸货">
import { ref, reactive } from 'vue'
import { POSTJSON } from '@/components/utils/http'
import { MessageBox } from '@/components/utils/api'
import { useWmsGlobal } from '@/store/wmsGlobal'
const wmsGlobal = useWmsGlobal()
const tableDatas = reactive({
  body: {
    //表数据
    head: 'arrived',
    url: '/InStore/getArrivedPage',
    params: { in_store_stat: 3 },
    type: 'POSTJSON'
  },
  confirm: true
})

const tableQuery = ref()
const onSubmit = () => {
  tableQuery.value.getData()
}

const forms = reactive({
  data: tableDatas.body.params,
  compValue: [
    {
      placeholder: '供应商',
      value: 'params',
      id: 'c_id',
      type: 'iconinput',
      onclick: () => {
        wmsGlobal.getClient(forms.data.params).then(data => {
          forms.data.c_id = data.id
          forms.data.params = data.name
        })
      }
    },
    {
      placeholder: '商品信息',
      value: 'paramsG',
      id: 'g_id',
      type: 'iconinput',
      onclick: () => {
        wmsGlobal.getGoods(forms.data.paramsG).then(data => {
          forms.data.g_id = data.id
          forms.data.paramsG = data.name
        })
      }
    },
    { label: '查询', type: 'button', onclick: onSubmit }
  ]
})

const confirmHandle = ({ row }) => {
  MessageBox('确认卸货【' + row.name + '】吗', () => {
    POSTJSON('/InStore/updateNoticeDetail', { in_store_stat: 4, id: row.id }).then(data => {
      if (data.code === 200) {
        onSubmit()
      }
    })
  })
}
</script>
